/*
 * @Author: 精金电子 maicent@qq.com
 * @Date: 2025-03-31 09:47:48
 * @LastEditors: 精金电子 maicent@qq.com
 * @LastEditTime: 2025-03-31 11:20:35
 * @FilePath: \web\src\api\system\user.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { request } from '@/utils/http/alova/index';
import qs from 'qs';

/**
 * @description: 获取用户信息
 */
export function getUserInfo() {
  return request.get('/auth/me');
}

interface LoginParams {
  username: string;
  password: string;
}

/**
 * @description: 用户登录
 */
export function login(data: LoginParams) {
  return request.post('/auth/login', {
    data: qs.stringify(data),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * @description: 用户修改密码
 */
export function changePassword(params, uid) {
  return Alova.Post(`/user/u${uid}/changepw`, { params });
}

/**
 * @description: 用户登出
 */
export function logout(params) {
  return Alova.Post('/login/logout', {
    params,
  });
}
